import 'package:flutter/material.dart';
import 'package:flutter_utils/flutter_utils.dart';
import 'package:flutter_widget/src/config/color_define.dart';
import 'package:flutter_widget/src/widget/effect/clip_widget.dart';
import 'package:flutter_widget/src/widget/text/text_format.dart';

enum TagWidgetStyle {
  brown,
  green,
  custom,
}

/* 通用标签组件（如风物标签） */
// ignore: must_be_immutable
class TagWidget extends StatelessWidget {
  final String title;
  Color? backgroundColor;
  Color? titleColor;
  final TagWidgetStyle style;

  TagWidget({
    Key? key,
    required this.title,
    this.backgroundColor,
    this.titleColor,
    this.style = TagWidgetStyle.custom,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    if (title.isEmpty == true) {
      return Container();
    }
    switch (style) {
      case TagWidgetStyle.brown:
        titleColor = FWColorPicker.colorFFA98A62;
        backgroundColor = FWColorPicker.colorFFF9F1DD;
        break;
      case TagWidgetStyle.green:
        titleColor = FWColorPicker.colorFF92AB86;
        backgroundColor = FWColorPicker.colorFFE7F8E9;
        break;
      case TagWidgetStyle.custom:
        break;
    }
    return ClipWidget(
      radius: 3,
      child: Container(
        height: AdaptUtil.fitSize(16),
        color: backgroundColor ?? FWColorPicker.white,
        alignment: Alignment.center,
        padding: const EdgeInsets.fromLTRB(3, 3, 3, 3),
        child: TextFormatWidget(
          title,
          fontSize: 11,
          color: titleColor ?? FWColorPicker.colorFFA98A62,
          height: 1,
        ),
      ),
    );
  }
}
